import { createStore, useStore as baseUseStore, createLogger, Store } from 'vuex'
import { App, InjectionKey } from 'vue'
import modules from '@/store/modules'
import { IStore } from './types'

export const key: InjectionKey<Store<IStore>> = Symbol()

const store = createStore<IStore>({
  modules,
})

// 定义你自己的“useStore”组合函数
export function useStore() {
  return baseUseStore(key)
}

export function setupStore(app: App) {
  app.use(store, key)
  console.log(store, 'vuex')
}

export default store
